<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>README - minitest: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="file">
  <!-- this is page.html -->
  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->


 <div class='wrapper hdiv'>

 


<nav id='vapp' role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#label-minitest-2F-7Btest-2Cspec-2Cmock-2Cbenchmark-7D">minitest/{test,spec,mock,benchmark}</a>
    <li><a href="#label-DESCRIPTION-3A">DESCRIPTION:</a>
    <li><a href="#label-FEATURES-2FPROBLEMS-3A">FEATURES/PROBLEMS:</a>
    <li><a href="#label-RATIONALE-3A">RATIONALE:</a>
    <li><a href="#label-SYNOPSIS-3A">SYNOPSIS:</a>
    <li><a href="#label-Unit+tests">Unit tests</a>
    <li><a href="#label-Specs">Specs</a>
    <li><a href="#label-Benchmarks">Benchmarks</a>
    <li><a href="#label-Mocks">Mocks</a>
    <li><a href="#label-Multi-threading+and+Mocks">Multi-threading and Mocks</a>
    <li><a href="#label-Stubs">Stubs</a>
    <li><a href="#label-Running+Your+Tests">Running Your Tests</a>
    <li><a href="#label-Rake+Tasks">Rake Tasks</a>
    <li><a href="#label-Rake+Task+Variables">Rake Task Variables</a>
    <li><a href="#label-Writing+Extensions">Writing Extensions</a>
    <li><a href="#label-Adding+custom+reporters">Adding custom reporters</a>
    <li><a href="#label-FAQ">FAQ</a>
    <li><a href="#label-What+versions+are+compatible+with+what-3F+Or+what+versions+are+supported-3F">What versions are compatible with what? Or what versions are supported?</a>
    <li><a href="#label-How+to+test+SimpleDelegates-3F">How to test SimpleDelegates?</a>
    <li><a href="#label-How+to+share+code+across+test+classes-3F">How to share code across test classes?</a>
    <li><a href="#label-How+to+run+code+before+a+group+of+tests-3F">How to run code before a group of tests?</a>
    <li><a href="#label-Why+am+I+seeing+uninitialized+constant+MiniTest-3A-3ATest+-28NameError-29-3F">Why am I seeing <code>uninitialized constant MiniTest::Test (NameError)</code>?</a>
    <li><a href="#label-Prominent+Projects+using+Minitest-3A">Prominent Projects using Minitest:</a>
    <li><a href="#label-Developing+Minitest-3A">Developing Minitest:</a>
    <li><a href="#label-Minitest-27s+own+tests+require+UTF-8+external+encoding.">Minitest’s own tests require UTF-8 external encoding.</a>
    <li><a href="#label-Minitest-27s+own+tests+require+GNU+-28or+similar-29+diff.">Minitest’s own tests require GNU (or similar) diff.</a>
    <li><a href="#label-Known+Extensions-3A">Known Extensions:</a>
    <li><a href="#label-Unknown+Extensions-3A">Unknown Extensions:</a>
    <li><a href="#label-Minitest+related+goods">Minitest related goods</a>
    <li><a href="#label-REQUIREMENTS-3A">REQUIREMENTS:</a>
    <li><a href="#label-INSTALL-3A">INSTALL:</a>
    <li><a href="#label-LICENSE-3A">LICENSE:</a>
  </ul>
</div>

  <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>

  <div id="project-metadata">
   <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
    
<div id="fileindex-section" class="nav-section">
  <h3>Pages</h3>

  <ul class="link-list">
    <li><a href="../minitest-5_20_0/History_rdoc.html">History</a>
    <li><a href="../minitest-5_20_0/README_rdoc.html">README</a>
  </ul>
</div>

   </div>
  </div>
</nav>


<!--  carbon ads here -->

<div id='extraz'>
  <div class='adzbox-index'  >
   
  </div>
 </div>         


<main role="main" aria-label="Page minitest-5.20.0/README.rdoc">

<h1 id="label-minitest-2F-7Btest-2Cspec-2Cmock-2Cbenchmark-7D">minitest/{test,spec,mock,benchmark}<span><a href="#label-minitest-2F-7Btest-2Cspec-2Cmock-2Cbenchmark-7D">&para;</a> <a href="#top">&uarr;</a></span></h1>
<dl class="rdoc-list note-list"><dt>home 
<dd>
<p><a href="https://github.com/minitest/minitest">github.com/minitest/minitest</a></p>
</dd><dt>bugs 
<dd>
<p><a href="https://github.com/minitest/minitest/issues">github.com/minitest/minitest/issues</a></p>
</dd><dt>rdoc 
<dd>
<p><a href="https://docs.seattlerb.org/minitest">docs.seattlerb.org/minitest</a></p>
</dd><dt>vim  
<dd>
<p><a href="https://github.com/sunaku/vim-ruby-minitest">github.com/sunaku/vim-ruby-minitest</a></p>
</dd><dt>emacs
<dd>
<p><a href="https://github.com/arthurnn/minitest-emacs">github.com/arthurnn/minitest-emacs</a></p>
</dd></dl>

<h2 id="label-DESCRIPTION-3A">DESCRIPTION:<span><a href="#label-DESCRIPTION-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking.</p>

<pre>&quot;I had a class with Jim Weirich on testing last week and we were
 allowed to choose our testing frameworks. Kirk Haines and I were
 paired up and we cracked open the code for a few test
 frameworks...

 I MUST say that minitest is *very* readable / understandable
 compared to the &#39;other two&#39; options we looked at. Nicely done and
 thank you for helping us keep our mental sanity.&quot;

-- Wayne E. Seguin</pre>

<p>minitest/test is a small and incredibly fast unit testing framework. It provides a rich set of assertions to make your tests clean and readable.</p>

<p>minitest/spec is a functionally complete spec engine. It hooks onto minitest/test and seamlessly bridges test assertions over to spec expectations.</p>

<p>minitest/benchmark is an awesome way to assert the performance of your algorithms in a repeatable manner. Now you can assert that your newb co-worker doesn’t replace your linear algorithm with an exponential one!</p>

<p>minitest/mock by Steven Baker, is a beautifully tiny mock (and stub) object framework.</p>

<p>minitest/pride shows pride in testing and adds coloring to your test output. I guess it is an example of how to write IO pipes too. :P</p>

<p>minitest/test is meant to have a clean implementation for language implementors that need a minimal set of methods to bootstrap a working test suite. For example, there is no magic involved for test-case discovery.</p>

<pre>&quot;Again, I can&#39;t praise enough the idea of a testing/specing
 framework that I can actually read in full in one sitting!&quot;

-- Piotr Szotkowski</pre>

<p>Comparing to rspec:</p>

<pre>rspec is a testing DSL. minitest is ruby.

-- Adam Hawkins, &quot;Bow Before MiniTest&quot;</pre>

<p>minitest doesn’t reinvent anything that ruby already provides, like: classes, modules, inheritance, methods. This means you only have to learn ruby to use minitest and all of your regular OO practices like extract-method refactorings still apply.</p>

<h2 id="label-FEATURES-2FPROBLEMS-3A">FEATURES/PROBLEMS:<span><a href="#label-FEATURES-2FPROBLEMS-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p>minitest/autorun - the easy and explicit way to run all your tests.</p>
</li><li>
<p>minitest/test - a very fast, simple, and clean test system.</p>
</li><li>
<p>minitest/spec - a very fast, simple, and clean spec system.</p>
</li><li>
<p>minitest/mock - a simple and clean mock/stub system.</p>
</li><li>
<p>minitest/benchmark - an awesome way to assert your algorithm’s performance.</p>
</li><li>
<p>minitest/pride - show your pride in testing!</p>
</li><li>
<p>minitest/test_task - a full-featured and clean rake task generator.</p>
</li><li>
<p>Incredibly small and fast runner, but no bells and whistles.</p>
</li><li>
<p>Written by squishy human beings. Software can never be perfect. We will all eventually die.</p>
</li></ul>

<h2 id="label-RATIONALE-3A">RATIONALE:<span><a href="#label-RATIONALE-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>See design_rationale.rb to see how specs and tests work in minitest.</p>

<h2 id="label-SYNOPSIS-3A">SYNOPSIS:<span><a href="#label-SYNOPSIS-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Given that you’d like to test the following class:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Meme</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">i_can_has_cheezburger?</span>
    <span class="ruby-string">&quot;OHAI!&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">will_it_blend?</span>
    <span class="ruby-string">&quot;YES!&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<h3 id="label-Unit+tests">Unit tests<span><a href="#label-Unit+tests">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Define your tests as methods beginning with <code>test_</code>.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;minitest/autorun&quot;</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">TestMeme</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Minitest</span><span class="ruby-operator">::</span><span class="ruby-constant">Test</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">setup</span>
    <span class="ruby-ivar">@meme</span> = <span class="ruby-constant">Meme</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_that_kitty_can_eat</span>
    <span class="ruby-identifier">assert_equal</span> <span class="ruby-string">&quot;OHAI!&quot;</span>, <span class="ruby-ivar">@meme</span>.<span class="ruby-identifier">i_can_has_cheezburger?</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_that_it_will_not_blend</span>
    <span class="ruby-identifier">refute_match</span> <span class="ruby-regexp">/^no/i</span>, <span class="ruby-ivar">@meme</span>.<span class="ruby-identifier">will_it_blend?</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_that_will_be_skipped</span>
    <span class="ruby-identifier">skip</span> <span class="ruby-string">&quot;test this later&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<h3 id="label-Specs">Specs<span><a href="#label-Specs">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;minitest/autorun&quot;</span>

<span class="ruby-identifier">describe</span> <span class="ruby-constant">Meme</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">before</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@meme</span> = <span class="ruby-constant">Meme</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">describe</span> <span class="ruby-string">&quot;when asked about cheeseburgers&quot;</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">it</span> <span class="ruby-string">&quot;must respond positively&quot;</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">_</span>(<span class="ruby-ivar">@meme</span>.<span class="ruby-identifier">i_can_has_cheezburger?</span>).<span class="ruby-identifier">must_equal</span> <span class="ruby-string">&quot;OHAI!&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">describe</span> <span class="ruby-string">&quot;when asked about blending possibilities&quot;</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">it</span> <span class="ruby-string">&quot;won&#39;t say no&quot;</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">_</span>(<span class="ruby-ivar">@meme</span>.<span class="ruby-identifier">will_it_blend?</span>).<span class="ruby-identifier">wont_match</span> <span class="ruby-regexp">/^no/i</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>For matchers support check out:</p>
<ul><li>
<p><a href="https://github.com/wojtekmach/minitest-matchers">github.com/wojtekmach/minitest-matchers</a></p>
</li><li>
<p><a href="https://github.com/rmm5t/minitest-matchers_vaccine">github.com/rmm5t/minitest-matchers_vaccine</a></p>
</li></ul>

<h3 id="label-Benchmarks">Benchmarks<span><a href="#label-Benchmarks">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Add benchmarks to your tests.</p>

<pre class="ruby"><span class="ruby-comment"># optionally run benchmarks, good for CI-only work!</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;minitest/benchmark&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;BENCH&quot;</span>]

<span class="ruby-keyword">class</span> <span class="ruby-constant">TestMeme</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Minitest</span><span class="ruby-operator">::</span><span class="ruby-constant">Benchmark</span>
  <span class="ruby-comment"># Override self.bench_range or default range is [1, 10, 100, 1_000, 10_000]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bench_my_algorithm</span>
    <span class="ruby-identifier">assert_performance_linear</span> <span class="ruby-value">0.9999</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-comment"># n is a range value</span>
      <span class="ruby-ivar">@obj</span>.<span class="ruby-identifier">my_algorithm</span>(<span class="ruby-identifier">n</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Or add them to your specs. If you make benchmarks optional, you’ll need to wrap your benchmarks in a conditional since the methods won’t be defined. In minitest 5, the describe name needs to match <code>/Bench(mark)?$/</code>.</p>

<pre class="ruby"><span class="ruby-identifier">describe</span> <span class="ruby-string">&quot;Meme Benchmark&quot;</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">if</span> <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;BENCH&quot;</span>] <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">bench_performance_linear</span> <span class="ruby-string">&quot;my_algorithm&quot;</span>, <span class="ruby-value">0.9999</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span>
      <span class="ruby-value">100</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
        <span class="ruby-ivar">@obj</span>.<span class="ruby-identifier">my_algorithm</span>(<span class="ruby-identifier">n</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>outputs something like:</p>

<pre># Running benchmarks:

TestBlah      100     1000    10000
bench_my_algorithm     0.006167        0.079279        0.786993
bench_other_algorithm  0.061679        0.792797        7.869932</pre>

<p>Output is tab-delimited to make it easy to paste into a spreadsheet.</p>

<h3 id="label-Mocks">Mocks<span><a href="#label-Mocks">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Mocks and stubs defined using terminology by Fowler &amp; Meszaros at <a href="https://www.martinfowler.com/bliki/TestDouble.html">www.martinfowler.com/bliki/TestDouble.html</a>:</p>

<p>“Mocks are pre-programmed with expectations which form a specification of the calls they are expected to receive. They can throw an exception if they receive a call they don’t expect and are checked during verification to ensure they got all the calls they were expecting.”</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">MemeAsker</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">meme</span>)
    <span class="ruby-ivar">@meme</span> = <span class="ruby-identifier">meme</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ask</span>(<span class="ruby-identifier">question</span>)
    <span class="ruby-identifier">method</span> = <span class="ruby-identifier">question</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-string">&quot; &quot;</span>, <span class="ruby-string">&quot;_&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot;?&quot;</span>
    <span class="ruby-ivar">@meme</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">method</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;minitest/autorun&quot;</span>

<span class="ruby-identifier">describe</span> <span class="ruby-constant">MemeAsker</span>, <span class="ruby-value">:ask</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">describe</span> <span class="ruby-string">&quot;when passed an unpunctuated question&quot;</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">it</span> <span class="ruby-string">&quot;should invoke the appropriate predicate method on the meme&quot;</span> <span class="ruby-keyword">do</span>
      <span class="ruby-ivar">@meme</span> = <span class="ruby-constant">Minitest</span><span class="ruby-operator">::</span><span class="ruby-constant">Mock</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-ivar">@meme_asker</span> = <span class="ruby-constant">MemeAsker</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@meme</span>
      <span class="ruby-ivar">@meme</span>.<span class="ruby-identifier">expect</span> <span class="ruby-value">:will_it_blend?</span>, <span class="ruby-value">:return_value</span>

      <span class="ruby-ivar">@meme_asker</span>.<span class="ruby-identifier">ask</span> <span class="ruby-string">&quot;will it blend&quot;</span>

      <span class="ruby-ivar">@meme</span>.<span class="ruby-identifier">verify</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<h4 id="label-Multi-threading+and+Mocks">Multi-threading and Mocks<span><a href="#label-Multi-threading+and+Mocks">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p><a href="../Minitest.html"><code>Minitest</code></a> mocks do not support multi-threading. If it works, fine, if it doesn’t you can use regular ruby patterns and facilities like local variables. Here’s an example of asserting that code inside a thread is run:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_called_inside_thread</span>
  <span class="ruby-identifier">called</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">pr</span> = <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> { <span class="ruby-identifier">called</span> = <span class="ruby-keyword">true</span> }
  <span class="ruby-identifier">thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">pr</span>)
  <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">join</span>
  <span class="ruby-identifier">assert</span> <span class="ruby-identifier">called</span>, <span class="ruby-string">&quot;proc not called&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

<h3 id="label-Stubs">Stubs<span><a href="#label-Stubs">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Mocks and stubs are defined using terminology by Fowler &amp; Meszaros at <a href="https://www.martinfowler.com/bliki/TestDouble.html">www.martinfowler.com/bliki/TestDouble.html</a>:</p>

<p>“Stubs provide canned answers to calls made during the test”.</p>

<p>Minitest’s stub method overrides a single method for the duration of the block.</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_stale_eh</span>
  <span class="ruby-identifier">obj_under_test</span> = <span class="ruby-constant">Something</span>.<span class="ruby-identifier">new</span>

  <span class="ruby-identifier">refute</span> <span class="ruby-identifier">obj_under_test</span>.<span class="ruby-identifier">stale?</span>

  <span class="ruby-constant">Time</span>.<span class="ruby-identifier">stub</span> <span class="ruby-value">:now</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-value">0</span>) <span class="ruby-keyword">do</span>   <span class="ruby-comment"># stub goes away once the block is done</span>
    <span class="ruby-identifier">assert</span> <span class="ruby-identifier">obj_under_test</span>.<span class="ruby-identifier">stale?</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>A note on stubbing: In order to stub a method, the method must actually exist prior to stubbing. Use a singleton method to create a new non-existing method:</p>

<pre>def obj_under_test.fake_method
  ...
end</pre>

<h3 id="label-Running+Your+Tests">Running Your Tests<span><a href="#label-Running+Your+Tests">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Ideally, you’ll use a rake task to run your tests (see below), either piecemeal or all at once. BUT! You don’t have to:</p>

<pre>% ruby -Ilib:test test/minitest/test_minitest_test.rb
Run options: --seed 37685

# Running:

...................................................................... (etc)

Finished in 0.107130s, 1446.8403 runs/s, 2959.0217 assertions/s.

155 runs, 317 assertions, 0 failures, 0 errors, 0 skips</pre>

<p>There are runtime options available, both from minitest itself, and also provided via plugins. To see them, simply run with <code>--help</code>:</p>

<pre>% ruby -Ilib:test test/minitest/test_minitest_test.rb --help
minitest options:
    -h, --help                       Display this help.
    -s, --seed SEED                  Sets random seed. Also via env. Eg: SEED=n rake
    -v, --verbose                    Verbose. Show progress processing files.
    -n, --name PATTERN               Filter run on /regexp/ or string.
    -e, --exclude PATTERN            Exclude /regexp/ or string from run.

Known extensions: pride, autotest
    -p, --pride                      Pride. Show your testing pride!
    -a, --autotest                   Connect to autotest server.</pre>

<h3 id="label-Rake+Tasks">Rake Tasks<span><a href="#label-Rake+Tasks">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>You can set up a rake task to run all your tests by adding this to your Rakefile:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;minitest/test_task&quot;</span>

<span class="ruby-constant">Minitest</span><span class="ruby-operator">::</span><span class="ruby-constant">TestTask</span>.<span class="ruby-identifier">create</span> <span class="ruby-comment"># named test, sensible defaults</span>

<span class="ruby-comment"># or more explicitly:</span>

<span class="ruby-constant">Minitest</span><span class="ruby-operator">::</span><span class="ruby-constant">TestTask</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:test</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">t</span>.<span class="ruby-identifier">libs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;test&quot;</span>
  <span class="ruby-identifier">t</span>.<span class="ruby-identifier">libs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;lib&quot;</span>
  <span class="ruby-identifier">t</span>.<span class="ruby-identifier">warning</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">t</span>.<span class="ruby-identifier">test_globs</span> = [<span class="ruby-string">&quot;test/**/*_test.rb&quot;</span>]
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">task</span> <span class="ruby-value">:default</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">:test</span>
</pre>

<p>Each of these will generate 4 tasks:</p>

<pre>rake test          :: Run the test suite.
rake test:cmd      :: Print out the test command.
rake test:isolated :: Show which test files fail when run separately.
rake test:slow     :: Show bottom 25 tests sorted by time.</pre>

<h3 id="label-Rake+Task+Variables">Rake Task Variables<span><a href="#label-Rake+Task+Variables">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>There are a bunch of variables you can supply to rake to modify the run.</p>

<pre>MT_LIB_EXTRAS :: Extra libs to dynamically override/inject for custom runs.
N             :: -n: Tests to run (string or /regexp/).
X             :: -x: Tests to exclude (string or /regexp/).
A             :: Any extra arguments. Honors shell quoting.
MT_CPU        :: How many threads to use for parallel test runs
SEED          :: -s --seed Sets random seed.
TESTOPTS      :: Deprecated, same as A
FILTER        :: Deprecated, same as A</pre>

<h2 id="label-Writing+Extensions">Writing Extensions<span><a href="#label-Writing+Extensions">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>To define a plugin, add a file named minitest/XXX_plugin.rb to your project/gem. That file must be discoverable via ruby’s LOAD_PATH (via rubygems or otherwise). <a href="../Minitest.html"><code>Minitest</code></a> will find and require that file using Gem.find_files. It will then try to call <code>plugin_XXX_init</code> during startup. The option processor will also try to call <code>plugin_XXX_options</code> passing the OptionParser instance and the current options hash. This lets you register your own command-line options. Here’s a totally bogus example:</p>

<pre class="ruby"><span class="ruby-comment"># minitest/bogus_plugin.rb:</span>

<span class="ruby-keyword">module</span> <span class="ruby-constant">Minitest</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">plugin_bogus_options</span>(<span class="ruby-identifier">opts</span>, <span class="ruby-identifier">options</span>)
    <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span> <span class="ruby-string">&quot;--myci&quot;</span>, <span class="ruby-string">&quot;Report results to my CI&quot;</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:myci</span>] = <span class="ruby-keyword">true</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:myci_addr</span>] = <span class="ruby-identifier">get_myci_addr</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:myci_port</span>] = <span class="ruby-identifier">get_myci_port</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">plugin_bogus_init</span>(<span class="ruby-identifier">options</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">reporter</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">MyCI</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:myci</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<h3 id="label-Adding+custom+reporters">Adding custom reporters<span><a href="#label-Adding+custom+reporters">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p><a href="../Minitest.html"><code>Minitest</code></a> uses composite reporter to output test results using multiple reporter instances. You can add new reporters to the composite during the init_plugins phase. As we saw in <code>plugin_bogus_init</code> above, you simply add your reporter instance to the composite via <code>&lt;&lt;</code>.</p>

<p><code>AbstractReporter</code> defines the API for reporters. You may subclass it and override any method you want to achieve your desired behavior.</p>
<dl class="rdoc-list note-list"><dt>start   
<dd>
<p>Called when the run has started.</p>
</dd><dt>record  
<dd>
<p>Called for each result, passed or otherwise.</p>
</dd><dt>report  
<dd>
<p>Called at the end of the run.</p>
</dd><dt>passed? 
<dd>
<p>Called to see if you detected any problems.</p>
</dd></dl>

<p>Using our example above, here is how we might implement MyCI:</p>

<pre class="ruby"><span class="ruby-comment"># minitest/bogus_plugin.rb</span>

<span class="ruby-keyword">module</span> <span class="ruby-constant">Minitest</span>
  <span class="ruby-keyword">class</span> <span class="ruby-constant">MyCI</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">AbstractReporter</span>
    <span class="ruby-identifier">attr_accessor</span> <span class="ruby-value">:results</span>, <span class="ruby-value">:addr</span>, <span class="ruby-value">:port</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span> <span class="ruby-identifier">options</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">results</span> = []
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">addr</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:myci_addr</span>]
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">port</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:myci_port</span>]
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">record</span> <span class="ruby-identifier">result</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">results</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">result</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">report</span>
      <span class="ruby-constant">CI</span>.<span class="ruby-identifier">connect</span>(<span class="ruby-identifier">addr</span>, <span class="ruby-identifier">port</span>).<span class="ruby-identifier">send_results</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">results</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># code from above...</span>
<span class="ruby-keyword">end</span>
</pre>

<h2 id="label-FAQ">FAQ<span><a href="#label-FAQ">&para;</a> <a href="#top">&uarr;</a></span></h2>

<h3 id="label-What+versions+are+compatible+with+what-3F+Or+what+versions+are+supported-3F">What versions are compatible with what? Or what versions are supported?<span><a href="#label-What+versions+are+compatible+with+what-3F+Or+what+versions+are+supported-3F">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p><a href="../Minitest.html"><code>Minitest</code></a> is a dependency of rails, which until fairly recently had an overzealous backwards compatibility policy. As such, I’m stuck supporting versions of ruby that are long past EOL. Hopefully I’ll be able to support only current versions of ruby sometime in the near future.</p>

<p>(As of 2023-03-05)</p>

<p>Current versions of rails: (<a href="https://endoflife.date/rails">endoflife.date/rails</a>)</p>

<pre>| rails | min ruby | rec ruby | minitest | status   |  EOL Date  |
|-------+----------+----------+----------+----------+------------|
|   7.0 | &gt;= 2.7   |      3.1 | &gt;= 5.1   | Current  | 2025-06-01?|
|   6.1 | &gt;= 2.5   |      3.0 | &gt;= 5.1   | Maint    | 2024-06-01?|
|   6.0 | &gt;= 2.5   |      2.6 | &gt;= 5.1   | Security | 2023-06-01 |
|   5.2 | &gt;= 2.2.2 |      2.5 | ~&gt; 5.1   | EOL      | 2022-06-01 |</pre>

<p>If you want to look at the requirements for a specific version, run:</p>

<pre>gem spec -r --ruby rails -v 7.0.0</pre>

<p>Current versions of ruby: (<a href="https://endoflife.date/ruby">endoflife.date/ruby</a>)</p>

<pre>| ruby | Status  |   EOL Date |
|------+---------+------------|
|  3.2 | Current | 2026-03-31 |
|  3.1 | Maint   | 2025-03-31 |
|  3.0 | Maint   | 2024-03-31 |
|  2.7 | Security| 2023-03-31 |
|  2.6 | EOL     | 2022-03-31 |
|  2.5 | EOL     | 2021-03-31 |</pre>

<h3 id="label-How+to+test+SimpleDelegates-3F">How to test SimpleDelegates?<span><a href="#label-How+to+test+SimpleDelegates-3F">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The following implementation and test:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Worker</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">SimpleDelegator</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">work</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">describe</span> <span class="ruby-constant">Worker</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">before</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@worker</span> = <span class="ruby-constant">Worker</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">it</span> <span class="ruby-string">&quot;must respond to work&quot;</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">_</span>(<span class="ruby-ivar">@worker</span>).<span class="ruby-identifier">must_respond_to</span> <span class="ruby-value">:work</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>outputs a failure:</p>

<pre>  1) Failure:
Worker#test_0001_must respond to work [bug11.rb:16]:
Expected #&lt;Object:0x007f9e7184f0a0&gt; (Object) to respond to #work.</pre>

<p>Worker is a SimpleDelegate which in 1.9+ is a subclass of BasicObject. Expectations are put on <a href="../Object.html"><code>Object</code></a> (one level down) so the Worker (SimpleDelegate) hits <code>method_missing</code> and delegates down to the <code>Object.new</code> instance. That object doesn’t respond to work so the test fails.</p>

<p>You can bypass <code>SimpleDelegate#method_missing</code> by extending the worker with <code>Minitest::Expectations</code>. You can either do that in your setup at the instance level, like:</p>

<pre class="ruby"><span class="ruby-identifier">before</span> <span class="ruby-keyword">do</span>
  <span class="ruby-ivar">@worker</span> = <span class="ruby-constant">Worker</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>)
  <span class="ruby-ivar">@worker</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">Minitest</span><span class="ruby-operator">::</span><span class="ruby-constant">Expectations</span>
<span class="ruby-keyword">end</span>
</pre>

<p>or you can extend the Worker class (within the test file!), like:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Worker</span>
  <span class="ruby-identifier">include</span> <span class="ruby-operator">::</span><span class="ruby-constant">Minitest</span><span class="ruby-operator">::</span><span class="ruby-constant">Expectations</span>
<span class="ruby-keyword">end</span>
</pre>

<h3 id="label-How+to+share+code+across+test+classes-3F">How to share code across test classes?<span><a href="#label-How+to+share+code+across+test+classes-3F">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Use a module. That’s exactly what they’re for:</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">UsefulStuff</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">useful_method</span>
    <span class="ruby-comment"># ...</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">describe</span> <span class="ruby-constant">Blah</span> <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">UsefulStuff</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_whatever</span>
    <span class="ruby-comment"># useful_method available here</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Remember, <code>describe</code> simply creates test classes. It’s just ruby at the end of the day and all your normal Good Ruby Rules (tm) apply. If you want to extend your test using setup/teardown via a module, just make sure you ALWAYS call super. before/after automatically call super for you, so make sure you don’t do it twice.</p>

<h3 id="label-How+to+run+code+before+a+group+of+tests-3F">How to run code before a group of tests?<span><a href="#label-How+to+run+code+before+a+group+of+tests-3F">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Use a constant with begin…end like this:</p>

<pre class="ruby"><span class="ruby-identifier">describe</span> <span class="ruby-constant">Blah</span> <span class="ruby-keyword">do</span>
  <span class="ruby-constant">SETUP</span> = <span class="ruby-keyword">begin</span>
     <span class="ruby-comment"># ... this runs once when describe Blah starts</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-comment"># ...</span>
<span class="ruby-keyword">end</span>
</pre>

<p>This can be useful for expensive initializations or sharing state. Remember, this is just ruby code, so you need to make sure this technique and sharing state doesn’t interfere with your tests.</p>

<h3 id="label-Why+am+I+seeing+uninitialized+constant+MiniTest-3A-3ATest+-28NameError-29-3F">Why am I seeing <code>uninitialized constant MiniTest::Test (NameError)</code>?<span><a href="#label-Why+am+I+seeing+uninitialized+constant+MiniTest-3A-3ATest+-28NameError-29-3F">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Are you running the test with Bundler (e.g. via <code>bundle exec</code> )? If so, in order to require minitest, you must first add the <code>gem &#39;minitest&#39;</code> to your Gemfile and run <code>bundle</code>. Once it’s installed, you should be able to require minitest and run your tests.</p>

<h2 id="label-Prominent+Projects+using+Minitest-3A">Prominent Projects using Minitest:<span><a href="#label-Prominent+Projects+using+Minitest-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p>arel</p>
</li><li>
<p>journey</p>
</li><li>
<p>mime-types</p>
</li><li>
<p>nokogiri</p>
</li><li>
<p>rails (active_support et al)</p>
</li><li>
<p>rake</p>
</li><li>
<p>rdoc</p>
</li><li>
<p>…and of course, everything from seattle.rb…</p>
</li></ul>

<h2 id="label-Developing+Minitest-3A">Developing Minitest:<span><a href="#label-Developing+Minitest-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p><a href="../Minitest.html"><code>Minitest</code></a> requires <a href="https://rubygems.org/gems/hoe">Hoe</a>.</p>

<h3 id="label-Minitest-27s+own+tests+require+UTF-8+external+encoding.">Minitest’s own tests require UTF-8 external encoding.<span><a href="#label-Minitest-27s+own+tests+require+UTF-8+external+encoding.">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>This is a common problem in Windows, where the default external Encoding is often CP850, but can affect any platform. <a href="../Minitest.html"><code>Minitest</code></a> can run test suites using any Encoding, but to run Minitest’s own tests you must have a default external Encoding of UTF-8.</p>

<p>If your encoding is wrong, you’ll see errors like:</p>

<pre>--- expected
+++ actual
@@ -1,2 +1,3 @@
 # encoding: UTF-8
 -&quot;Expected /\\w+/ to not match \&quot;blah blah blah\&quot;.&quot;
 +&quot;Expected /\\w+/ to not match # encoding: UTF-8
 +\&quot;blah blah blah\&quot;.&quot;</pre>

<p>To check your current encoding, run:</p>

<pre>ruby -e &#39;puts Encoding.default_external&#39;</pre>

<p>If your output is something other than UTF-8, you can set the RUBYOPTS env variable to a value of ‘-Eutf-8’. Something like:</p>

<pre>RUBYOPT=&#39;-Eutf-8&#39; ruby -e &#39;puts Encoding.default_external&#39;</pre>

<p>Check your OS/shell documentation for the precise syntax (the above will not work on a basic Windows CMD prompt, look for the SET command). Once you’ve got it successfully outputing UTF-8, use the same setting when running rake in <a href="../Minitest.html"><code>Minitest</code></a>.</p>

<h3 id="label-Minitest-27s+own+tests+require+GNU+-28or+similar-29+diff.">Minitest’s own tests require GNU (or similar) diff.<span><a href="#label-Minitest-27s+own+tests+require+GNU+-28or+similar-29+diff.">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>This is also a problem primarily affecting Windows developers. PowerShell has a command called diff, but it is not suitable for use with <a href="../Minitest.html"><code>Minitest</code></a>.</p>

<p>If you see failures like either of these, you are probably missing diff tool:</p>

<pre>  4) Failure:
TestMinitestUnitTestCase#test_assert_equal_different_long [D:/ruby/seattlerb/minitest/test/minitest/test_minitest_test.rb:936]:
Expected: &quot;--- expected\n+++ actual\n@@ -1 +1 @@\n-\&quot;hahahahahahahahahahahahahahahahahahahaha\&quot;\n+\&quot;blahblahblahblahblahblahblahblahblahblah\&quot;\n&quot;
  Actual: &quot;Expected: \&quot;hahahahahahahahahahahahahahahahahahahaha\&quot;\n  Actual: \&quot;blahblahblahblahblahblahblahblahblahblah\&quot;&quot;

  5) Failure:
TestMinitestUnitTestCase#test_assert_equal_different_collection_hash_hex_invisible [D:/ruby/seattlerb/minitest/test/minitest/test_minitest_test.rb:845]:
Expected: &quot;No visible difference in the Hash#inspect output.\nYou should look at the implementation of #== on Hash or its members.\n
{1=&gt;#&lt;Object:0xXXXXXX&gt;}&quot;
  Actual: &quot;Expected: {1=&gt;#&lt;Object:0x00000003ba0470&gt;}\n  Actual: {1=&gt;#&lt;Object:0x00000003ba0448&gt;}&quot;</pre>

<p>If you use Cygwin or MSYS2 or similar there are packages that include a GNU diff for Windows. If you don’t, you can download GNU diffutils from <a href="http://gnuwin32.sourceforge.net/packages/diffutils.htm">gnuwin32.sourceforge.net/packages/diffutils.htm</a> (make sure to add it to your PATH).</p>

<p>You can make sure it’s installed and path is configured properly with:</p>

<pre class="ruby"><span class="ruby-identifier">diff</span>.<span class="ruby-identifier">exe</span> <span class="ruby-operator">-</span><span class="ruby-identifier">v</span>
</pre>

<p>There are multiple lines of output, the first should be something like:</p>

<pre>diff (GNU diffutils) 2.8.1</pre>

<p>If you are using PowerShell make sure you run diff.exe, not just diff, which will invoke the PowerShell built in function.</p>

<h2 id="label-Known+Extensions-3A">Known Extensions:<span><a href="#label-Known+Extensions-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt>capybara_minitest_spec      
<dd>
<p>Bridge between Capybara RSpec matchers and <a href="../Minitest/Spec.html"><code>Minitest::Spec</code></a> expectations (e.g. <code>page.must_have_content(&quot;Title&quot;)</code>).</p>
</dd><dt>color_pound_spec_reporter   
<dd>
<p>Test names print Ruby <a href="../Object.html"><code>Object</code></a> types in color with your <a href="../Minitest.html"><code>Minitest</code></a> Spec style tests.</p>
</dd><dt>minispec-metadata           
<dd>
<p>Metadata for describe/it blocks &amp; CLI tag filter. E.g. <code>it &quot;requires JS driver&quot;, js: true do</code> &amp; <code>ruby test.rb --tag js</code> runs tests tagged :js.</p>
</dd><dt>minispec-rails              
<dd>
<p>Minimal support to use Spec style in Rails 5+.</p>
</dd><dt>mini-apivore                
<dd>
<p>for swagger based automated API testing.</p>
</dd><dt>minitest-around             
<dd>
<p>Around block for minitest. An alternative to setup/teardown dance.</p>
</dd><dt>minitest-assert_errors      
<dd>
<p>Adds <a href="../Minitest.html"><code>Minitest</code></a> assertions to test for errors raised or not raised by <a href="../Minitest.html"><code>Minitest</code></a> itself.</p>
</dd><dt>minitest-autotest           
<dd>
<p>autotest is a continuous testing facility meant to be used during development.</p>
</dd><dt>minitest-bacon              
<dd>
<p>minitest-bacon extends minitest with bacon-like functionality.</p>
</dd><dt>minitest-bang               
<dd>
<p>Adds support for RSpec-style let! to immediately invoke let statements before each test.</p>
</dd><dt>minitest-bisect             
<dd>
<p>Helps you isolate and debug random test failures.</p>
</dd><dt>minitest-blink1_reporter    
<dd>
<p>Display test results with a Blink1.</p>
</dd><dt>minitest-capistrano         
<dd>
<p>Assertions and expectations for testing Capistrano recipes.</p>
</dd><dt>minitest-capybara           
<dd>
<p>Capybara matchers support for minitest unit and spec.</p>
</dd><dt>minitest-cc                 
<dd>
<p>It provides minimal information about code coverage.</p>
</dd><dt>minitest-chef-handler       
<dd>
<p>Run <a href="../Minitest.html"><code>Minitest</code></a> suites as Chef report handlers</p>
</dd><dt>minitest-ci                 
<dd>
<p>CI reporter plugin for <a href="../Minitest.html"><code>Minitest</code></a>.</p>
</dd><dt>minitest-context            
<dd>
<p>Defines contexts for code reuse in <a href="../Minitest.html"><code>Minitest</code></a> specs that share common expectations.</p>
</dd><dt>minitest-debugger           
<dd>
<p>Wraps assert so failed assertions drop into the ruby debugger.</p>
</dd><dt>minitest-display            
<dd>
<p>Patches <a href="../Minitest.html"><code>Minitest</code></a> to allow for an easily configurable output.</p>
</dd><dt>minitest-documentation      
<dd>
<p>Minimal documentation format inspired by rspec’s.</p>
</dd><dt>minitest-doc_reporter       
<dd>
<p>Detailed output inspired by rspec’s documentation format.</p>
</dd><dt>minitest-emoji              
<dd>
<p>Print out emoji for your test passes, fails, and skips.</p>
</dd><dt>minitest-english            
<dd>
<p>Semantically symmetric aliases for assertions and expectations.</p>
</dd><dt>minitest-excludes           
<dd>
<p>Clean API for excluding certain tests you don’t want to run under certain conditions.</p>
</dd><dt>minitest-fail-fast          
<dd>
<p>Reimplements RSpec’s “fail fast” feature</p>
</dd><dt>minitest-filecontent        
<dd>
<p>Support unit tests with expectation results in files. Differing results will be stored again in files.</p>
</dd><dt>minitest-filesystem         
<dd>
<p>Adds assertion and expectation to help testing filesystem contents.</p>
</dd><dt>minitest-firemock           
<dd>
<p>Makes your <a href="../Minitest.html"><code>Minitest</code></a> mocks more resilient.</p>
</dd><dt>minitest-focus              
<dd>
<p>Focus on one test at a time.</p>
</dd><dt>minitest-gcstats            
<dd>
<p>A minitest plugin that adds a report of the top tests by number of objects allocated.</p>
</dd><dt>minitest-global_expectations
<dd>
<p>Support minitest expectation methods for all objects</p>
</dd><dt>minitest-great_expectations 
<dd>
<p>Generally useful additions to minitest’s assertions and expectations.</p>
</dd><dt>minitest-growl              
<dd>
<p>Test notifier for minitest via growl.</p>
</dd><dt>minitest-happy              
<dd>
<p>GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!</p>
</dd><dt>minitest-have_tag           
<dd>
<p>Adds <a href="../Minitest.html"><code>Minitest</code></a> assertions to test for the existence of HTML tags, including contents, within a provided string.</p>
</dd><dt>minitest-heat               
<dd>
<p>Reporting that builds a heat map of failure locations</p>
</dd><dt>minitest-hooks              
<dd>
<p>Around and before_all/after_all/around_all hooks</p>
</dd><dt>minitest-hyper              
<dd>
<p>Pretty, single-page HTML reports for your <a href="../Minitest.html"><code>Minitest</code></a> runs</p>
</dd><dt>minitest-implicit-subject   
<dd>
<p>Implicit declaration of the test subject.</p>
</dd><dt>minitest-instrument         
<dd>
<p>Instrument ActiveSupport::Notifications when test method is executed.</p>
</dd><dt>minitest-instrument-db      
<dd>
<p>Store information about speed of test execution provided by minitest-instrument in database.</p>
</dd><dt>minitest-junit              
<dd>
<p>JUnit-style XML reporter for minitest.</p>
</dd><dt>minitest-keyword            
<dd>
<p>Use <a href="../Minitest.html"><code>Minitest</code></a> assertions with keyword arguments.</p>
</dd><dt>minitest-libnotify          
<dd>
<p>Test notifier for minitest via libnotify.</p>
</dd><dt>minitest-line               
<dd>
<p>Run test at line number.</p>
</dd><dt>minitest-logger             
<dd>
<p>Define assert_log and enable minitest to test log messages. Supports Logger and Log4r::Logger.</p>
</dd><dt>minitest-macruby            
<dd>
<p>Provides extensions to minitest for macruby UI testing.</p>
</dd><dt>minitest-matchers           
<dd>
<p>Adds support for RSpec-style matchers to minitest.</p>
</dd><dt>minitest-matchers_vaccine   
<dd>
<p>Adds assertions that adhere to the matcher spec, but without any expectation infections.</p>
</dd><dt>minitest-metadata           
<dd>
<p>Annotate tests with metadata (key-value).</p>
</dd><dt>minitest-mock_expectations  
<dd>
<p>Provides method call assertions for minitest.</p>
</dd><dt>minitest-mongoid            
<dd>
<p>Mongoid assertion matchers for <a href="../Minitest.html"><code>Minitest</code></a>.</p>
</dd><dt>minitest-must_not           
<dd>
<p>Provides must_not as an alias for wont in <a href="../Minitest.html"><code>Minitest</code></a>.</p>
</dd><dt>minitest-optional_retry     
<dd>
<p>Automatically retry failed test to help with flakiness.</p>
</dd><dt>minitest-osx                
<dd>
<p>Reporter for the Mac OS X notification center.</p>
</dd><dt>minitest-parallel_fork      
<dd>
<p>Fork-based parallelization</p>
</dd><dt>minitest-parallel-db        
<dd>
<p>Run tests in parallel with a single database.</p>
</dd><dt>minitest-power_assert       
<dd>
<p>PowerAssert for <a href="../Minitest.html"><code>Minitest</code></a>.</p>
</dd><dt>minitest-predicates         
<dd>
<p>Adds support for .predicate? methods.</p>
</dd><dt>minitest-profile            
<dd>
<p>List the 10 slowest tests in your suite.</p>
</dd><dt>minitest-rails              
<dd>
<p><a href="../Minitest.html"><code>Minitest</code></a> integration for Rails 3.x.</p>
</dd><dt>minitest-rails-capybara     
<dd>
<p>Capybara integration for Minitest::Rails.</p>
</dd><dt>minitest-reporters          
<dd>
<p>Create customizable <a href="../Minitest.html"><code>Minitest</code></a> output formats.</p>
</dd><dt>minitest-rg                 
<dd>
<p>Colored red/green output for <a href="../Minitest.html"><code>Minitest</code></a>.</p>
</dd><dt>minitest-rspec_mocks        
<dd>
<p>Use RSpec Mocks with <a href="../Minitest.html"><code>Minitest</code></a>.</p>
</dd><dt>minitest-server             
<dd>
<p>minitest-server provides a client/server setup with your minitest process, allowing your test run to send its results directly to a handler.</p>
</dd><dt>minitest-sequel             
<dd>
<p><a href="../Minitest.html"><code>Minitest</code></a> assertions to speed-up development and testing of Ruby Sequel database setups.</p>
</dd><dt>minitest-shared_description 
<dd>
<p>Support for shared specs and shared spec subclasses</p>
</dd><dt>minitest-should_syntax      
<dd>
<p>RSpec-style <code>x.should == y</code> assertions for <a href="../Minitest.html"><code>Minitest</code></a>.</p>
</dd><dt>minitest-shouldify          
<dd>
<p>Adding all manner of shoulds to <a href="../Minitest.html"><code>Minitest</code></a> (bad idea)</p>
</dd><dt>minitest-snail              
<dd>
<p>Print a list of tests that take too long</p>
</dd><dt>minitest-spec-context       
<dd>
<p>Provides rspec-ish context method to <a href="../Minitest/Spec.html"><code>Minitest::Spec</code></a>.</p>
</dd><dt>minitest-spec-expect        
<dd>
<p>Expect syntax for <a href="../Minitest/Spec.html"><code>Minitest::Spec</code></a> (e.g. expect(sequences).to_include :celery_man).</p>
</dd><dt>minitest-spec-magic         
<dd>
<p><a href="../Minitest/Spec.html"><code>Minitest::Spec</code></a> extensions for Rails and beyond.</p>
</dd><dt>minitest-spec-rails         
<dd>
<p>Drop in <a href="../Minitest/Spec.html"><code>Minitest::Spec</code></a> superclass for ActiveSupport::TestCase.</p>
</dd><dt>minitest-sprint             
<dd>
<p>Runs (Get it? It’s fast!) your tests and makes it easier to rerun individual failures.</p>
</dd><dt>minitest-stately            
<dd>
<p>Find leaking state between tests</p>
</dd><dt>minitest-stub_any_instance  
<dd>
<p>Stub any instance of a method on the given class for the duration of a block.</p>
</dd><dt>minitest-stub-const         
<dd>
<p>Stub constants for the duration of a block.</p>
</dd><dt>minitest-tags               
<dd>
<p>Add tags for minitest.</p>
</dd><dt>minitest-unordered          
<dd>
<p>Adds a new assertion to minitest for checking the contents of a collection, ignoring element order.</p>
</dd><dt>minitest-vcr                
<dd>
<p>Automatic cassette management with <a href="../Minitest/Spec.html"><code>Minitest::Spec</code></a> and VCR.</p>
</dd><dt>minitest_log                
<dd>
<p>Adds structured logging, data explication, and verdicts.</p>
</dd><dt>minitest_owrapper           
<dd>
<p>Get tests results as a TestResult object.</p>
</dd><dt>minitest_should             
<dd>
<p>Shoulda style syntax for minitest test::unit.</p>
</dd><dt>minitest_tu_shim            
<dd>
<p>Bridges between test/unit and minitest.</p>
</dd><dt>mongoid-minitest            
<dd>
<p><a href="../Minitest.html"><code>Minitest</code></a> matchers for Mongoid.</p>
</dd><dt>mutant-minitest             
<dd>
<p><a href="../Minitest.html"><code>Minitest</code></a> integration for mutant.</p>
</dd><dt>pry-rescue                  
<dd>
<p>A pry plugin w/ minitest support. See pry-rescue/minitest.rb.</p>
</dd><dt>rematch                     
<dd>
<p>Declutter your test files from large hardcoded data and update them automatically when your code changes.</p>
</dd><dt>rspec2minitest              
<dd>
<p>Easily translate any RSpec matchers to <a href="../Minitest.html"><code>Minitest</code></a> assertions and expectations.</p>
</dd><dt>stubberry                   
<dd>
<p>Multiple stubbing ‘berries’, sweet and useful  stub helpers and assertions. ( stub_must,  assert_method_called, stubbing ORM objects by id )</p>
</dd></dl>

<h2 id="label-Unknown+Extensions-3A">Unknown Extensions:<span><a href="#label-Unknown+Extensions-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Authors… Please send me a pull request with a description of your minitest extension.</p>
<ul><li>
<p>assay-minitest</p>
</li><li>
<p>detroit-minitest</p>
</li><li>
<p>em-minitest-spec</p>
</li><li>
<p>flexmock-minitest</p>
</li><li>
<p>guard-minitest</p>
</li><li>
<p>guard-minitest-decisiv</p>
</li><li>
<p>minitest-activemodel</p>
</li><li>
<p>minitest-ar-assertions</p>
</li><li>
<p>minitest-capybara-unit</p>
</li><li>
<p>minitest-colorer</p>
</li><li>
<p>minitest-deluxe</p>
</li><li>
<p>minitest-extra-assertions</p>
</li><li>
<p>minitest-rails-shoulda</p>
</li><li>
<p>minitest-spec</p>
</li><li>
<p>minitest-spec-should</p>
</li><li>
<p>minitest-sugar</p>
</li><li>
<p>spork-minitest</p>
</li></ul>

<h2 id="label-Minitest+related+goods"><a href="../Minitest.html"><code>Minitest</code></a> related goods<span><a href="#label-Minitest+related+goods">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p>minitest/pride fabric: <a href="https://www.spoonflower.com/fabric/3928730-again-by-katie_allen">www.spoonflower.com/fabric/3928730-again-by-katie_allen</a></p>
</li></ul>

<h2 id="label-REQUIREMENTS-3A">REQUIREMENTS:<span><a href="#label-REQUIREMENTS-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p>Ruby 2.3+. No magic is involved. I hope.</p>
</li></ul>

<h2 id="label-INSTALL-3A">INSTALL:<span><a href="#label-INSTALL-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">sudo</span> <span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">minitest</span>
</pre>

<p>On 1.9, you already have it. To get newer candy you can still install the gem, and then requiring “minitest/autorun” should automatically pull it in. If not, you’ll need to do it yourself:</p>

<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-string">&quot;minitest&quot;</span>     <span class="ruby-comment"># ensures you&quot;re using the gem, and not the built-in MT</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;minitest/autorun&quot;</span>

<span class="ruby-comment"># ... usual testing stuffs ...</span>
</pre>

<p>DO NOTE: There is a serious problem with the way that ruby 1.9/2.0 packages their own gems. They install a gem specification file, but don’t install the gem contents in the gem path. This messes up Gem.find_files and many other things (gem which, gem contents, etc).</p>

<p>Just install minitest as a gem for real and you’ll be happier.</p>

<h2 id="label-LICENSE-3A">LICENSE:<span><a href="#label-LICENSE-3A">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>(The MIT License)</p>

<p>Copyright © Ryan Davis, seattle.rb</p>

<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>

<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>

<p>THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>

</main>

</div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

